﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraZoom : MonoBehaviour
{
        public bool isActive = false;
        public float zoomSpeed = 100;
        public float maxDistance = -16;
        public float minDistance = -26;

        void Start()
        {

        }

        void Update()
        {
                if (isActive)
                {
                        float move = Input.GetAxis("Mouse ScrollWheel");
                        move = zoomSpeed * Time.deltaTime * move;

                        move += this.transform.localPosition.z;

                        if (move <= minDistance)
                        {
                                move = minDistance;
                        }
                        else if (move >= maxDistance)
                        {
                                move = maxDistance;
                        }

                        Vector3 loPos = new Vector3(this.transform.localPosition.x, this.transform.localPosition.y, move);

                        this.transform.localPosition = loPos;
                }
        }
}
